package com.edu.exam.enums;

import com.edu.exam.enums.core.BaseEnum;

/**
 * 模板复杂度级别枚举
 */
public enum TemplateComplexityLevel implements BaseEnum {

    /**
     * 简单
     */
    SIMPLE("SIMPLE", "简单"),

    /**
     * 中等
     */
    MEDIUM("MEDIUM", "中等"),

    /**
     * 复杂
     */
    COMPLEX("COMPLEX", "复杂"),

    /**
     * 高级
     */
    ADVANCED("ADVANCED", "高级");

    private final String code;
    private final String description;

    TemplateComplexityLevel(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    @Override
    public String getDescription() {
        return description;
    }

    /**
     * 从代码创建枚举实例
     *
     * @param code 枚举代码
     * @return 对应的枚举实例
     */
    public static TemplateComplexityLevel fromCode(String code) {
        for (TemplateComplexityLevel level : values()) {
            if (level.getCode().equals(code)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown template complexity level code: " + code);
    }

    /**
     * 从描述创建枚举实例
     *
     * @param description 枚举描述
     * @return 对应的枚举实例
     */
    public static TemplateComplexityLevel fromDescription(String description) {
        for (TemplateComplexityLevel level : values()) {
            if (level.getDescription().equals(description)) {
                return level;
            }
        }
        throw new IllegalArgumentException("Unknown template complexity level description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}